﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyTruongMamNon.Man_Hinh
{
    public partial class frmTra_Cuu_Hoc_Sinh : Form
    {
        public frmTra_Cuu_Hoc_Sinh()
        {
            InitializeComponent();
        }
        public void HienThiHocSinh()
        {
            string sql="select * from DMHS";
            DataTable dt = new DataTable();
            dt=Thu_Vien.ExecuteQuery(sql);
            dtgHoc_Sinh.DataSource = dt;
            //dtgHoc_Sinh.DataBindings.Add("text", dt, "MaHS");
           // dtgHoc_Sinh.DataBindings.Add("text", dt, "Ho");
            //dtgHoc_Sinh.DataBindings.Add("text", dt, "Ten");


        }
        public void HienThiNienKhoa()
        {
            string sql = "select * from NAM_HOC";
            DataTable dt = new DataTable();
            dt = Thu_Vien.ExecuteQuery(sql);
            cboNamHoc.DataSource = dt;
            cboNamHoc.DisplayMember = "Namhoc";
  
        }
          public void HienThiKhoi()
        {
            string sql = "select * from KHOI";
            DataTable dt = new DataTable();
            dt = Thu_Vien.ExecuteQuery(sql);
            cboKhoi.DataSource = dt;
            cboKhoi.DisplayMember = "Makhoi";

  
        }
          public void TimHSTheoNam()
          {
             
                  string sql = "select hs.*, Namhoc, Malop from DMHS hs inner join HS_LOP l on hs.Mahs=l.Mahs where NamHoc='" + cboNamHoc.Text + "'";
                  DataTable dt = new DataTable();
                  dt = Thu_Vien.ExecuteQuery(sql);
                  dtgHoc_Sinh.DataSource = dt;
             
          }
          public void TimHSTheoKhoi()
          {

              string sql = "select hs.*, Namhoc, MaKhoi from DMHS hs inner join HS_LOP l on hs.Mahs=l.Mahs where NamHoc='" + cboNamHoc.Text + "'";
              DataTable dt = new DataTable();
              dt = Thu_Vien.ExecuteQuery(sql);
              dtgHoc_Sinh.DataSource = dt;

          }

        private void frmTra_Cuu_Hoc_Sinh_Load(object sender, EventArgs e)
        {
            HienThiHocSinh();
            HienThiNienKhoa();
            HienThiKhoi();
            txtTongSoHS.Text=dtgHoc_Sinh.RowCount.ToString();
        }

        private void cboNamHoc_SelectedIndexChanged(object sender, EventArgs e)
        {
            TimHSTheoNam();
        }
    }
}
